const fileSession = require('think-session-file');
const redisCache = require('think-cache-redis');
const path = require('path');
const mysql = require('think-model-mysql');

exports.session = {
  type: 'file',
  common: {
    cookie: {
      name: 'thinkjs',
      keys: ['signature key'],
      signed: true
    }
  },
  file: {
    handle: fileSession,
    sessionPath: path.join(think.ROOT_PATH, 'runtime/session')
  }
};

// exports.cache = {
//   type: 'redis',
//   common: {
//     timeout: 24 * 3600 * 1000 // millisecond
//   },
//   redis: {
//     handle: redisCache,
//     host: '172.19.19.7',
//     port: '6379',
//     password: '123456',
//     db: '0'
//   }
// };
exports.cache = {
  type: 'redis',
  common: {
    timeout: 24 * 3600 * 1000 // millisecond
  },
  redis: {
    handle: redisCache,
    host: 'redis-test2.surongapp.com',
    port: '6379',
    password: 'redis123',
    db: '0'
  }
};
exports.model = {
  type: 'mysql', // 默认使用的类型，调用时可以指定参数切换
  common: { // 通用配置
    logConnect: true, // 是否打印数据库连接信息
    logSql: true, // 是否打印 SQL 语句
    logger: msg => think.logger.info(msg) // 打印信息的 logger
  },
  mysql: { // mysql 配置
    handle: mysql, // Adapter handle
    host: '172.19.19.7',
    port: '3306',
    database: 'moyan',
    user: 'root',
    password: '123456',
    prefix: '',
    encoding: 'utf8'
  }
};
